package com.alks.entity.data.enums;

import com.alks.entity.exception.ServiceErrorException;
import lombok.Getter;

/**
 * @author MS
 * @since 2024/11/25下午4:47
 */
@Getter
public enum CompanyEnum {
    /**
     * 荣阳
     */
    RY("BF","RY","荣阳"),
    RS("HF","RS","荣信");

    private String oldId;
    private String newId;
    private String companyName;

    CompanyEnum(String oldId,String newId,String companyName){
        this.oldId = oldId;
        this.newId = newId;
        this.companyName = companyName;
    }

    public static String updateId(String oldId) {
        for (CompanyEnum companyEnum : CompanyEnum.values()) {
            if (companyEnum.oldId.equals(oldId)) {
                return companyEnum.newId;
            }
        }
        throw new ServiceErrorException("不存在的公司ID");
    }

    public static String getCompanyName(String oldId) {
        for (CompanyEnum companyEnum : CompanyEnum.values()) {
            if (companyEnum.oldId.equals(oldId)) {
                return companyEnum.companyName;
            }
        }
        throw new ServiceErrorException("不存在的公司ID");
    }

}
